package com.snowRemovingUser.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.snowRemovingUser.domain.TCommentRiskLevelRule;
import com.snowRemovingUser.service.ITCommentRiskLevelRuleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * comment风险等级规则Controller
 * 
 * @author lg
 * @date 2024-04-10
 */
@RestController
@RequestMapping("/snowRemoving/rule")
public class TCommentRiskLevelRuleController extends BaseController
{
    @Autowired
    private ITCommentRiskLevelRuleService tCommentRiskLevelRuleService;

    /**
     * 查询comment风险等级规则列表
     */
    @PreAuthorize("@ss.hasPermi('snowRemoving:rule:list')")
    @GetMapping("/list")
    public TableDataInfo list(TCommentRiskLevelRule tCommentRiskLevelRule)
    {
        startPage();
        List<TCommentRiskLevelRule> list = tCommentRiskLevelRuleService.selectTCommentRiskLevelRuleList(tCommentRiskLevelRule);
        return getDataTable(list);
    }

    /**
     * 导出comment风险等级规则列表
     */
    @PreAuthorize("@ss.hasPermi('snowRemoving:rule:export')")
    @Log(title = "comment风险等级规则", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TCommentRiskLevelRule tCommentRiskLevelRule)
    {
        List<TCommentRiskLevelRule> list = tCommentRiskLevelRuleService.selectTCommentRiskLevelRuleList(tCommentRiskLevelRule);
        ExcelUtil<TCommentRiskLevelRule> util = new ExcelUtil<TCommentRiskLevelRule>(TCommentRiskLevelRule.class);
        util.exportExcel(response, list, "comment风险等级规则数据");
    }

    /**
     * 获取comment风险等级规则详细信息
     */
    @PreAuthorize("@ss.hasPermi('snowRemoving:rule:query')")
    @GetMapping(value = "/{riskLevelRuleId}")
    public AjaxResult getInfo(@PathVariable("riskLevelRuleId") String riskLevelRuleId)
    {
        return success(tCommentRiskLevelRuleService.selectTCommentRiskLevelRuleByRiskLevelRuleId(riskLevelRuleId));
    }

    /**
     * 新增comment风险等级规则
     */
    @PreAuthorize("@ss.hasPermi('snowRemoving:rule:add')")
    @Log(title = "comment风险等级规则", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TCommentRiskLevelRule tCommentRiskLevelRule)
    {
        return toAjax(tCommentRiskLevelRuleService.insertTCommentRiskLevelRule(tCommentRiskLevelRule));
    }

    /**
     * 修改comment风险等级规则
     */
    @PreAuthorize("@ss.hasPermi('snowRemoving:rule:edit')")
    @Log(title = "comment风险等级规则", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TCommentRiskLevelRule tCommentRiskLevelRule)
    {
        return toAjax(tCommentRiskLevelRuleService.updateTCommentRiskLevelRule(tCommentRiskLevelRule));
    }

    /**
     * 删除comment风险等级规则
     */
    @PreAuthorize("@ss.hasPermi('snowRemoving:rule:remove')")
    @Log(title = "comment风险等级规则", businessType = BusinessType.DELETE)
	@DeleteMapping("/{riskLevelRuleIds}")
    public AjaxResult remove(@PathVariable String[] riskLevelRuleIds)
    {
        return toAjax(tCommentRiskLevelRuleService.deleteTCommentRiskLevelRuleByRiskLevelRuleIds(riskLevelRuleIds));
    }
}
